# 导包
import time
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By

# 创建浏览器驱动
driver = webdriver.Chrome()
# 获取访问页面
driver.get("http://121.43.169.97:8848/pageA.html")
# 放大浏览器
driver.maximize_window()

action = ActionChains(driver)

# 获取 源元素
source = driver.find_element(By.CSS_SELECTOR, "#div1")
# 获取 目标元素
target = driver.find_element(By.CSS_SELECTOR, "#div2")

time.sleep(3)
# 方法1：直接拖拽到目标元素
action.drag_and_drop(source, target).perform()

time.sleep(3)
# 方法2：通过坐标偏移量执行
action.click_and_hold(source).move_by_offset(300, 300).release().perform()

time.sleep(3)
driver.quit()